1. Field of the Invention
The invention relates to a prediction module, more particularly to a prediction module which is disposed at a decoding end and which conforms to the Motion Picture Expert Group (MPEG) specification.
2. Description of the Related Art
The H.264 encoding standard is a dynamic video compression standard jointly set by the International Tele-communication Union (ITU) and the Motion Picture Expert Group (MPEG) of the International Standard Organization (ISO). Therefore, the standard is also referred to as MPEG-4 Advanced Video Coding (MPEG-4 AVC).
The encoding end samples a dynamic image at a specific sampling frequency into a plurality of static images. Each static image includes a plurality of regions having 16×16 pixels. Each region is compressed into a luminance macroblock and two chrominance macroblocks to represent the luminance and chrominance of the 16×16 region. The two chrominance macroblocks include a Chrominance blue (Cb) macroblock and a Chrominance red (Cr) macroblock.
The luminance macroblock may be, e.g., 16×16 pixels, 16×8 pixels, 8×16 pixels, 8×8 pixels, 8×4 pixels, 4×8 pixels, and 4×4 pixels, according to the size defined according to the standard. The size of the chrominance macroblock is one-fourth of the size of the luminance macroblock, and thus may be 8×8 pixels, 8×4 pixels, 4×8 pixels, 4×4 pixels, 2×4 pixels, 4×2 pixels, and 2×2 pixels.
The encoding end needs to send the static images to the decoding end for image processing at the decoding end. However, the encoding end does not send the static images directly to the decoding end. Instead, pixel values of a plurality of macroblocks included in each static image are first predicted according to a specific sequence and parameters defined by the H.264 standard, with reference to pixels of an encoded reference block. However, since the macroblocks obtained from prediction at the encoding end are not the actual macroblocks in the static image, there is a difference therebetween. Therefore, the encoding end will also calculate a residual value between each actual macroblock and the corresponding macroblock obtained from prediction, and encode the standard syntax correspondingly used for predicting each macroblock and the residual value into a bit-stream, which is sent to the decoding end so as to reduce the amount of data transmitted between the encoding end and the decoding end.
The decoding end decodes the bit stream upon receipt of the same so as to obtain the standard syntax correspondingly used by the encoding end for predicting each macroblock, and the residual value of each macroblock. Then, according to the standard syntax correspondingly used for predicting each macroblock, and by carrying out the same prediction scheme adopted at the encoding end, macroblocks corresponding to those obtained from prediction at the encoding end can be obtained. The actual macroblock can be recovered by adding the corresponding residual value to the macroblock obtained from prediction. Then, the actual macroblocks are grouped together in an appropriate manner to result in the static images, thereby reconstructing the dynamic image.
The decoding end needs to refer to pixels of a decoded reference block at the decoding end when calculating the pixel values of a macroblock to be predicted. The reference block and the macroblock to be predicted may belong to different static images (which is hereinafter referred to as inter prediction) or the same static image (hereinafter referred to as intra prediction).
When the reference block and the macroblock to be predicted belong to the same static image, the reference block includes pixels of predicted macroblocks surrounding the macroblock, the pixels being adjacent to the macroblock to be predicted.
Referring to FIG. 1, the macroblock to be predicted includes 4×4 pixels, and is located in a region surrounded by line segments L1-L4. The coordinates of the pixel at the upper left corner of the macroblock to be predicted are [0,0]. The x-coordinates of the pixels are incremented in a horizontal rightwise direction, and the y-coordinates of the pixels are incremented in a vertical downward direction. The reference block includes pixels Q, h0-h7, and v0-v7 that are located in macroblocks at the upper side, the upper left side, the upper right side, and the left side of the macroblock to be predicted and that are adjacent to the macroblock to be predicted. When a macroblock to be predicted is calculated using intra prediction, the pixels of the macroblock to be predicted are determined by the pixel values of Q, h0-h7, and v0-v7 of the reference block.
When the reference block and the macroblock to be predicted belong to different static images, the reference block includes pixels of one or a plurality of decoded static images. The static image in which the reference block is located is a reference index of the macroblock to be predicted. The size of the reference block is correlated to the motion vector of the macroblock to be predicted. Referring to FIG. 2, the decoding end refers to a reference block when calculating a macroblock to be predicted in a static image F(4). The reference index of the macroblock to be predicted points to a previously decoded static image F(2). The pixel pointed to by the motion vector in the static image F(2) is the pixel at the upper leftmost corner of the macroblock to be predicted.
As shown in FIG. 3, a conventional decoding device at the decoding end includes an entropy decoder 91, an inverse quantizer 92, an inverse discrete cosine transformer 93, an adder 94, a de-blocking filter 95, a frame buffer 96, and a prediction module 97. The prediction module 97 includes an intra predictor 971, an inter predictor 972, and a prediction mode controller 973.
The entropy decoder 91 receives an encoded bit stream from an encoding end (not shown), decodes the bit stream using, e.g., a variable length decoding scheme of the Huffman code, and sends the decoded bit stream to the inverse quantizer 92 and the prediction mode controller 973. The inverse quantizer 92 performs inverse quantization of the decoded bit stream, and sends the bit stream to the inverse discrete cosine transformer 93 for inverse discrete cosine transformation so as to transform data in the frequency domain to data in the spatial domain, and so as to calculate a residual value.
The adder 94 adds up the residual value outputted by the inverse discrete cosine transformer 93 and the macroblock obtained by prediction using the prediction module 97, and sends the result to the de-blocking filter 95. The de-blocking filter 95 subjects the data outputted by the adder 94 to a smoothing de-blocking operation to obtain the actual macroblock in the static image, and outputs the same to the frame buffer 96. The frame buffer 96 stores the macroblocks outputted by the de-blocking filter 95, composes the same into a decoded static image for displaying by an audio-visual medium, and sends the pixel values of the static image to the prediction module 97.
The prediction mode controller 973 obtains the standard syntax used for predicting the macroblock at the encoding end from the decoded bit stream outputted by the entropy decoder 91. The standard syntax includes the motion vector and reference index of each macroblock, as well as the macroblock size and macroblock type. The prediction mode controller 973 sends the decoded bit stream to the intra predictor 971 or the inter predictor 972 according to the standard syntax. The macroblock type includes luminance and chrominance macroblocks.
The intra predictor 971 and the inter predictor 972 calculate the pixel values of the macroblock to be predicted using intra prediction or inter prediction according to the reference block, and sends the calculated macroblock to the adder 94.
When the reference block and the macroblock to be predicted belong to the same static image (intra prediction), the intra predictor 971 can calculate the macroblock to be predicted using different modes according to the type and size of the macroblock to be predicted. For example, when the size of the luminance macroblock to be predicted is 4×4 pixels or 8×8 pixels, the intra predictor 971 can use nine modes of prediction, which are, respectively: mode 0, vertical; mode 1, horizontal; mode 3, diagonal down left; mode 4, diagonal down right; mode 5, vertical left; mode 6, horizontal down; mode 7, vertical right; mode 8, horizontal up; and DC mode.
Since the macroblocks whose pixels the intra predictor 971 needs to refer to when executing intra prediction are macroblocks surrounding the macroblock to be predicted, the intra predictor 971 can store all the pixels that need to be referred to without requiring too large a storage space. Therefore, the frame buffer 96 does not need to send the pixel data to the intra predictor 971, and the intra predictor 971 shown in FIG. 3 does not need to be connected electrically to the frame buffer 96.
When the size of the luminance macroblock to be predicted is 16×16 pixels, the intra predictor 971 can use four modes of prediction, which are, respectively, a vertical mode, a horizontal mode, a DC mode, and a plane mode.
When the macroblock to be predicted is a chrominance macroblock, regardless of the size of the chrominance macroblock to be predicted, the intra predictor 971 can use four modes of prediction, which are, respectively, a vertical mode, a horizontal mode, a DC mode, and a plane mode.
The inter predictor 972 calculates the pixel values of the macroblock to be predicted using inter prediction according to the pixel value of the reference block outputted by the frame buffer 96. The static image outputted by the frame buffer 96 corresponds to the reference index, and the reference block is correlated to the pixel in the static image which the motion vector points to.
Since the reference block only belongs to the same static image as or a different static image than the macroblock to be predicted, the prediction module 97 will calculate the macroblock to be predicted using one of intra prediction and inter prediction. Besides, the macroblocks of each static image have to be processed in sequence, and a next macroblock will not be processed until processing of the current macroblock is finished. Therefore, the prediction module 97 will not use the intra predictor 971 simultaneously with the inter predictor 972 when calculating the macroblock to be predicted, and the conventional prediction module 97 includes both the intra predictor 971 and the inter predictor 972. For example, the prediction module described in the article “A software-hardware co-implementation of MPEG-4 advanced video coding (AVC) decoder with block level pipelining” by S. H. Wang and T. C. et al. in Journal of VLSI Signal Processing, 2005, is one with two predictors that are not used simultaneously. As a result, the efficiency of hardware utilization is unsatisfactory.